<template>
  <div style="height: 100vh">
    <div
        style="width: 500px;height: 400px;background-color: #ffffff;border-radius: 10px;margin: 150px auto;padding: 50px" class="bg">
      <div style="margin: 30px;text-align: center;font-size: 30px;font-weight: bold;color: white">登录</div>
      <el-form :model="admin" ref="loginForm">
        <el-form-item label="学工号/教职工号" prop="username">
          <el-input v-model="admin.username" placeholder="请输入学工号/教职工号" ></el-input>
<!--          <el-input v-model="params.state"  disabled placeholder="学工号/教职工号"></el-input> //可看不可编辑-->
        </el-form-item>
        <el-form-item label="请输入密码（UID号）" prop="password">
          <el-input v-model="admin.password" placeholder="请输入密码（UID号）" type="password"></el-input>
<!--          type="password" 变成小点点（不可视）elementUI里面找-->
        </el-form-item>
        <el-form-item>
          <el-button style="width: 20%;display:block;margin:0 auto;color: white" type="primary" @click="login">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<style>
.bg {
  background-image: url("../../images/2.jpg");
}
</style>

<script>

import request from "@/utils/request";
import Cookies from 'js-cookie'

export default {
  name: "Login",
  data() {
    return {
      admin: {}
    }
  },
  methods: {
    login() {
      request.put('/admin/login', this.admin).then(res => {
        if (res.code === '200') {
          this.$notify.success("登录成功")
          if(res.data !== null) {
            Cookies.set('admin',JSON.stringify(res.data));
          }
          this.$router.push('/')
        } else {
          this.$notify.error(res.msg)
        }
      })
    }

  }
}
</script>

<style scoped>

</style>


<!--<template>-->
<!--  <div style="height: 100vh">-->
<!--    <div-->
<!--        style="width: 500px;height: 400px;background-color: #ffffff;border-radius: 10px;margin: 150px auto;padding: 50px">-->
<!--      <div style="margin: 30px;text-align: center;font-size: 30px;font-weight: bold">登录</div>-->
<!--      <el-form :model="params" ref="loginForm">-->
<!--        <el-form-item label="学工号/教职工号">-->
<!--          <el-input v-model="params.state" placeholder="学工号/教职工号"></el-input>-->
<!--          &lt;!&ndash;          <el-input v-model="params.state"  disabled placeholder="学工号/教职工号"></el-input> //可看不可编辑&ndash;&gt;-->
<!--        </el-form-item>-->
<!--        <el-form-item label="请输入密码（UID号）">-->
<!--          <el-input v-model="params.roomid" placeholder="请输入密码（UID号）"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item>-->
<!--          <el-button style="width: 20%;display:block;margin:0 auto;" type="primary" @click="login">登录</el-button>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
<!--    </div>-->
<!--  </div>-->
<!--</template>-->

<!--<script>-->
<!--import request from "@/utils/request";-->

<!--export default {-->
<!--  name: "Login.vue",-->
<!--  data() {-->
<!--    return {-->
<!--      params: []-->
<!--    }-->
<!--  },-->
<!--  methods: {-->
<!--    login() {-->
<!--      request.put('/user/login', this.params).then(res => {-->
<!--        if (res.code === '200') {-->

<!--          this.$router.push('/')-->
<!--          this.$notify.success("登录成功")-->
<!--        } else {-->
<!--          this.$notify.error(res.msg)-->
<!--        }-->
<!--      })-->
<!--    }-->

<!--  }-->
<!--}-->
<!--</script>-->

<!--<style scoped>-->

<!--</style>-->